package com.drg.center;

import com.guaike.core.entity.result.Result;
import com.guaike.core.redis.annotation.EnableRedissonClient;
import com.guaike.core.web.annotation.EnableSingleGroupSwagger;
import com.guaike.core.web.utils.ErrorUtil;
import org.dromara.x.file.storage.spring.EnableFileStorage;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@EnableFileStorage
@ControllerAdvice
@EnableSingleGroupSwagger
@EnableRedissonClient
@ComponentScan({"com.drg", "com.guaike"})
@MapperScan("com.drg.center.mapper")
@SpringBootApplication
public class DrgCenterServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(DrgCenterServiceApplication.class, args);
    }

    /**
     * 全局异常处理
     *
     * @param ex Exception
     * @return R
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result<String> defaultExceptionHandler(Exception ex) {
        return ErrorUtil.handException(ex, "system-center");
    }

}
